package com.ht.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ht.domain.bo.TbJuniorBO;
import com.ht.domain.po.TbJunior;
import com.ht.mapper.JuniorMapper;
import com.ht.service.JuniorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 专科表service
 */
@Service
public class JuniorServiceImpl implements JuniorService {

    @Autowired
    private JuniorMapper juniorMapper;

    /**
     * 根据科室id查询下面对应的专科
     * @param departmentId
     * @return
     */
    @Override
    public List<TbJuniorBO> findJuniorListByDepartmentId(Long departmentId) {
        List<TbJunior> juniorList = juniorMapper.selectList(new QueryWrapper<TbJunior>().eq("department_id", departmentId));
        List<TbJuniorBO> juniorBOList = new ArrayList<>();
        for (TbJunior junior:juniorList) {
            TbJuniorBO juniorBO = new TbJuniorBO(junior);
            juniorBOList.add(juniorBO);
        }
        return juniorBOList;
    }
}
